Skip to content

feat(datetime): add header parts#30945

Open
thetaPC wants to merge 12 commits intofeature-8.8from
FW-6997
Open

feat(datetime): add header parts#30945
thetaPC wants to merge 12 commits intofeature-8.8from
FW-6997

Conversation

@thetaPC
Copy link
Contributor

@thetaPC thetaPC commented Feb 4, 2026

Issue number: resolves #30083, resolves #30830


What is the current behavior?

There's no way to customize the header when using a grid style. This includes the entire header, prev/next buttons, and the days of the week container. The only section that can customized within the header is the month/year picker. This limits developers from being able to make changes to match their styles.

What is the new behavior?

  • Added parts to the header container, prev/next buttons, prev button, next button, and days of the week container.
  • Added tests for the next parts.
  • Added a test for the existing month/year picker part.
  • Updated the custom test page to show how to use all the parts mentioned: header container, month/year picker, prev/next buttons, prev button, next button, and days of the week container

Does this introduce a breaking change?

  • Yes
  • No

Other information

Preview

@vercel
Copy link

vercel bot commented Feb 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ionic-framework Ready Ready Preview, Comment Feb 17, 2026 10:25pm

Request Review

@github-actions github-actions bot added the package: core @ionic/core package label Feb 4, 2026
expect(backgroundColor).toBe('rgb(218, 216, 255)');
});

test('should be able to customize month/year picker part within the grid style', async ({ page }, testInfo) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We didn't have a test for this so I added it.

@thetaPC thetaPC marked this pull request as ready for review February 4, 2026 22:39
@thetaPC thetaPC requested a review from a team as a code owner February 4, 2026 22:39
@thetaPC thetaPC requested review from OS-jacobbell and ShaneK and removed request for OS-jacobbell February 4, 2026 22:39
@thetaPC thetaPC changed the title feat(datetime): add header parts to grid style feat(datetime): add header parts Feb 6, 2026
Copy link
Member

@ShaneK ShaneK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me! Awesome work!

Copy link
Member

@brandyscarney brandyscarney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! A few requests & questions.

aria-label="Previous month"
disabled={prevMonthDisabled}
onClick={() => this.prevMonth()}
part="prev-next-buttons prev-button"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm torn on the prev-next-buttons naming because usually we just name it a shared name like in the components that have helper text & error text we call them supporting-text:

<div class="helper-text" part="supporting-text helper-text">{helperText}</div>
<div class="error-text" part="supporting-text error-text">{errorText}</div>

I would think we would do something similar here like:

Suggested change
part="prev-next-buttons prev-button"
part="navigation-button previous-button"

I spelled out previous because using full words improves readability and makes translations easier.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Navigation buttons sound better! 8dc99f4

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aria-label="Next month"
disabled={nextMonthDisabled}
onClick={() => this.nextMonth()}
part="prev-next-buttons next-button"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
part="prev-next-buttons next-button"
part="navigation-buttons next-button"

See my previous comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expect(backgroundColor).toBe('rgb(255, 165, 0)');
});

test('should be able to customize calendar header part within the grid style', async ({ page }) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to say within the grid style on all of these?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expect(backgroundColor).toBe('rgb(173, 216, 230)');
});

test('should be able to customize prev/next buttons part within the grid style', async ({ page }, testInfo) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we combine this test with the previous & next button part tests? Maybe the one targeting both could apply background color while the individual parts could apply text color.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

`
<style>
ion-datetime::part(days-of-week) {
background-color: #9ad162;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Can we stick with named colors to make it easier to verify the rgb matches up?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we expose datetime-selected-date?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

</div>
</div>
<div class="calendar-days-of-week" aria-hidden="true">
<div class="calendar-days-of-week" aria-hidden="true" part="days-of-week">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we should call this calendar-days-of-week to match the naming of calendar-header? I am wondering if it's confusing that we have calendar-day and calendar-header but then stop prefixing with calendar. We probably can't enforce this though without causing breaking changes since month-year-button is released already.

ion-datetime,part,calendar-day
ion-datetime,part,calendar-header
ion-datetime,part,datetime-header
ion-datetime,part,days-of-week
ion-datetime,part,month-year-button
ion-datetime,part,next-button
ion-datetime,part,prev-button
ion-datetime,part,prev-next-buttons
ion-datetime,part,time-button
ion-datetime,part,wheel
ion-datetime,part,wheel-item

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not against it. The original thought was trying to keep it short but I'm convinced to keep it consistent. We should reconsider the naming during ionic modular work. 0bc7bf3

* layout with `presentation="date-time"` or `"time-date"`.
* @part time-button active - The time picker button when the picker is open.
*
* @part calendar-header - The calendar header manages the date navigation controls (month/year picker and prev/next buttons) and the days of the week when using a grid style layout.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @part calendar-header - The calendar header manages the date navigation controls (month/year picker and prev/next buttons) and the days of the week when using a grid style layout.
* @part calendar-header - The calendar header manages the date navigation controls (month/year picker and previous/next buttons) and the days of the week when using a grid style layout.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Co-authored-by: Brandy Smith <6577830+brandyscarney@users.noreply.github.com>
Co-authored-by: Brandy Smith <brandyscarney@users.noreply.github.com>
Co-authored-by: Brandy Smith <6577830+brandyscarney@users.noreply.github.com>
Co-authored-by: Brandy Smith <6577830+brandyscarney@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: core @ionic/core package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants